<template>
  <div class="right">
    我是权限管理组件
    <el-tree
      :data="rrightTree"
      show-checkbox
      default-expand-all
      node-key="rightid"
      ref="RrightTree"
      highlight-current
      :props="defaultProps">
    </el-tree>
    <div class="buttons">
      <el-button @click="getCheckedKeys">通过 key 获取</el-button>
    </div>
  </div>
</template>

<script>
import axios from '../../utils/request'
export default {
  name: 'RightManage',
  created () {
    this.initRrightTree()
  },
  methods: {
    async initRrightTree () {
      let response = await axios({
        method: 'get',
        url: 'admin/role/getRrightTree'
      })
      if (response.code === '200') {
        this.rrightTree = response.data
      }
    },
    getCheckedKeys () {
      console.log(this.$refs.RrightTree.getCheckedKeys())
    }
  },

  data () {
    return {
      rrightTree: [],
      defaultProps: {
        children: 'children',
        label: 'righttext'
      }
    }
  }
}
</script>

<style scoped>

</style>
